package com.spx.core.ui.views;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import com.spx.core.CoreActivator;
import com.spx.core.types.Activity;
import com.spx.core.types.Role;
import com.spx.core.types.User;
import com.spx.kernel.types.ModelType;

public class AuthorityLabelProvider extends LabelProvider implements ITableLabelProvider
{
	public String getColumnText(Object obj, int index)
	{
		return getText(obj);
	}

	@Override
	public String getText(Object object)
	{
		final String result = ((ModelType) object).getName();
		return result;

	}

	public Image getColumnImage(Object obj, int index)
	{
		return getImage(obj);
	}

	@Override
	public Image getImage(Object obj)
	{
		Image image = null;

		if (obj instanceof User)
		{
			image = CoreActivator.getImageDescriptor("icons/user_16.gif").createImage();
		} else if (obj instanceof Role)
		{
			image = CoreActivator.getImageDescriptor("icons/role_16.gif").createImage();
		} else if (obj instanceof Activity)
		{
			image = CoreActivator.getImageDescriptor("icons/action_16.gif").createImage();
		}

		return image;
	}
}